/*  header-comment
/*  file   : /Users/allan/Desktop/workSpace/react-hrm-h5/src/actions/hrCenter/index
/*  author :
/*  date   : 2017-6-4 18:27:59
/*  last   : 2017-11-1 12:1:20
*/
import fetch from "../../utils/fetch.js";

export const fetchFragmentaryEmployeeCount = params => dispatch =>
  fetch(`/hrmregister/mobile/emp/getFragmentaryEmployeeList`, {
    isCache: params.isCache,
    method: "GET",
    meta: {
      dipId: 69978,
      showLoading: false
    }
  });

//v3
export const fetchHrCenterInfo = params => dispatch =>
  fetch(`/hrmregister/mobile/workbench/getHrCenterInfoV3`, {
    isCache: params.isCache,
    method: "GET",
    meta: {
      dipId: 67203
    }
  });
//v2
export const fetchHrCenterInfoV2 = params =>
  fetch(`/hrmregister/mobile/workbench/getHrCenterInfoV2`, {
    method: "GET",
    meta: {
      dipId: 67203,
      showLoading: params.showLoading
    }
  });

export const fetchHrCenterTopInfo = params => () =>
  fetch(`/hrmregister/mobile/hrmSchedule/getScheduleIndexInfo`, {
    isCache: params.isCache,
    meta: {
      dipId: 69637,
      showLoading: false
    }
  });

export const checkPermissionV2 = () => () => {
  if (window.__auth) {
    return Promise.resolve({ result: window.__auth, success: true });
  }
  return fetch(`/hrmregister/mobile/workbench/checkPermissionV2`, {
    meta: {
      showLoading: false,
      dipId: 67232
    }
  });
};

export const fetchServiceCenterInfo = params => dispatch =>
  fetch(`/hrmregister/mobile/workbench/getEmpCenterInfo`, {
    isCache: params.isCache,
    method: "GET",
    meta: {
      dipId: 68822
    }
  }).then(res => {
    if (res && res.success) {
      dispatch({ type: "GET_HR_CENTER_LIST", result: res.result });
    }
    return res;
  });

export const inviteOpenHrmCenter = () => () =>
  fetch(`/hrmregister/mobile/workbench/inviteOpenHrmCenter`, {
    meta: {
      dipId: 69140,
      showLoading: false
    }
  });
